/**
 * 
 */
package com.jcode.netty.core;

import com.jcode.netty.protocol.Protocol;

import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelId;

/**
 * Channel包装器
 * 
 * @Author dreajay
 * @DateTime 2016年12月3日 上午11:24:55
 * 
 */
public class ChannelWrapper {

	private final ChannelFuture channelFuture;

	/** 协议 TCP、WebSocket、HTTP */
	private final Protocol protocol;

	public ChannelWrapper(ChannelFuture channelFuture) {
		this.channelFuture = channelFuture;
		this.protocol = Protocol.TCP;
	}

	public ChannelWrapper(ChannelFuture channelFuture, Protocol protocol) {
		this.channelFuture = channelFuture;
		this.protocol = protocol;
	}

	public boolean isOK() {
		return (this.channelFuture.channel() != null && this.channelFuture.channel().isActive());
	}

	public boolean isWriteable() {
		return this.channelFuture.channel().isWritable();
	}

	public Channel getChannel() {
		return this.channelFuture.channel();
	}

	public ChannelId getChannelId() {
		return this.channelFuture.channel().id();
	}

	public ChannelFuture getChannelFuture() {
		return channelFuture;
	}

	public Protocol getProtocol() {
		return protocol;
	}

}
